﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tools;
using 纺织贸易管理系统;

namespace 后整理管理系统.其他窗体
{
    public partial class 修改卷 : Form
    {
        private List<JuanHaoTable> Rolls = new List<JuanHaoTable>();
        public 修改卷(List<JuanHaoTable> rolls)
        {
            this.Rolls = rolls;
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            switch (comboBox1.Text)
            {
                case "品名":
                    foreach (var item in Rolls)
                    {
                        item.SampleName = txtValue.Text;
                    }
                    break;
                case "颜色":
                    foreach (var item in Rolls)
                    {
                        item.yanse = txtValue.Text;
                    }
                    break;
                case "订单号":
                    foreach (var item in Rolls)
                    {
                        item.OrderNum = txtValue.Text;
                    }
                    break;
                case "款号":
                    foreach (var item in Rolls)
                    {
                        item.kuanhao = txtValue.Text;
                    }
                    break;
            }
            try
            {
                using (var trans = Connect.dbcontext.UseTran())
                {
                    Connect.dbcontext.Updateable(Rolls).ExecuteCommand();
                    trans.CommitTran();
                    this.Close();
                }
            }
            catch (Exception ex) 
            {
               ShowMessageBox.ShowErrorBox("修改失败！"+ex.Message);
            }
        }
    }
}
